package com.lkd.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lkd.entity.Task;
import com.lkd.mapper.TaskMapper;
import com.lkd.service.TaskService;
import com.lkd.vo.TaskVo;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.List;

/**
 * <p>
 * 工单表 服务实现类
 * </p>
 *
 * @author 聂德祥
 * @since 2024-08-20
 */
@Service
public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements TaskService {

    @Override
    public List<TaskVo> getTaskCount(LocalDateTime start, LocalDateTime end) {
        TaskVo taskCount1 = getBaseMapper().getTaskCount(start, end,"运营员");
        TaskVo taskCount2 = getBaseMapper().getTaskCount(start, end,"维修员");
        List<TaskVo> taskCount = List.of(taskCount1, taskCount2);
        taskCount.stream().forEach(taskVo -> {
            if(taskVo.getTotal()==null){
                taskVo.setTotal(0);
            }
            if(taskVo.getProgressTotal()==null){
                taskVo.setProgressTotal(0);
        }
            if(taskVo.getCancelTotal()==null){
                taskVo.setCancelTotal(0);
            }
            if(taskVo.getCompletedTotal()==null){
                taskVo.setCompletedTotal(0);
            }


            taskVo.setWorkerCount(0);
            taskVo.setRepair(false);
        });
        return taskCount;
    }
}
